/**
 * 
 */
package com.thomsonreuters.elektronunified;

import java.util.ArrayList;

/**
 * Data object representing a request to the EU system for data.
 * <P> 
 * Every request must include a list of RIC items to be requested/cancelled 
 * and optionally a user identifier to group items and/or a view specification.
 */
public class RequestItem 
{
    public enum EURequestTypeEnum
    {
        /// <summary>
        ///  Request items. 
        /// </summary>
        subscription,
        /// <summary>
        ///  Cancel items. 
        /// </summary>
        cancellation
    }
	
	String userIdentifier = "EURequest";
	EURequestTypeEnum requestType = EURequestTypeEnum.subscription;
	
	ArrayList<String> itemArray = new ArrayList<String>();
	ArrayList<String> viewArray = new ArrayList<String>();
	
	
	public String getUserIdentifier() {	return userIdentifier; }
	
	/**
	 * Sets a user specified identifier. 
	 * <P>
	 * The identifier is returned in messages (images and updates) received from the EU service.
	 * <P>
	 * The identifier may be provided to cancellation requests to un-subscribe to a set of instruments in one call. 
	 */
	public void setUserIdentifier(String userIdentifier) { this.userIdentifier = userIdentifier;}
	
	/**
	 * Returns the request type, either subscription or cancellation.
	 */
	protected EURequestTypeEnum getRequestType() { return requestType; }
	
	/**
	 * Sets the request type, either subscription or cancellation. Defaults to subscription.
	 */
	public void setRequestType(EURequestTypeEnum requestType) { this.requestType = requestType;}
	
	/**
	 * Returns the ArrayList of items (RICs) set in the request.
	 */	
	protected ArrayList<String> getItemArray() { return itemArray;	}
	
	/**
	 * Sets an ArrayList of items (RICs) to be subscribed in the request.
	 */	
	protected void setItemArray(ArrayList<String> itemArray) {	this.itemArray = itemArray;	}

	/**
	 * Returns the ArrayList of Field Identifiers defining the view specification in the request.
	 */	
	protected ArrayList<String> getViewArray() { return viewArray;	}
	
	/**
	 * Sets an ArrayList of Field Identifiers (FIDs) to define the view specification in the request.
	 */			
	protected void setViewArray(ArrayList<String> viewArray) {	this.viewArray = viewArray;	}
	
	/**
	 * Adds an item (RIC) for subscription/cancellation to the request.
	 */			
	public void addRequestItem(String item) { this.itemArray.add(item);	}
	
	/**
	 * Adds a Field Identifier (FID) to the view specification for the request.
	 * <P>
	 * A view specification is used to specify a subset of fields to be returned for an item.
	 * <P>
	 * If not set, all available fields for the item are returned.
	 * <P>
	 * More information on the available field content can be found in the EU content guide.
	 */				
	public void addViewItem(String item) { this.viewArray.add(item); }
	
}
